var t = getApp();

Page({
    data: {
        userInfo: [],
        RenewShow: !1
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "VIP"
        }), this.getData(), this.getUser(), this.setData({
            plugin_setting: wx.getStorageSync("yz_basic_info").plugin_setting.debt_shop || {}
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    toOrder: function() {
        wx.navigateTo({
            url: "/packageA/member/myOrder_v2/myOrder_v2?member_type=3"
        });
    },
    toDetail: function() {
        wx.navigateTo({
            url: "/packageF/debt/purchaseDetails/purchaseDetails?isvip=true"
        });
    },
    toBindDetail: function() {
        wx.navigateTo({
            url: "/packageF/debt/vipBindRecord/vipBindRecord"
        });
    },
    applyTap: function() {
        wx.navigateTo({
            url: "/packageF/debt/debtapply/debtapply?type=3"
        });
    },
    renewTap: function() {
        var t = this.data.datainfo.vip_id;
        this.setData({
            RenewShow: !0,
            renewUserId: t
        }), this.getGoodsCount();
    },
    toDetailVip: function() {
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + this.data.vip_goods_id
        });
    },
    toShop: function() {
        wx.navigateTo({
            url: "/packageF/debt/debtor/debtorShop/debtorShop?kid=" + this.data.datainfo.debtor_id
        });
    },
    removeTap: function() {
        var t = this;
        wx.showModal({
            content: "是否确认解除绑定",
            success: function(e) {
                e.confirm ? t.removePost() : e.cancel && console.log("用户点击取消");
            }
        });
    },
    removePost: function() {
        var e = this, o = t.getNetAddresss("plugin.debt-shop.frontend.apply.deleteBindApply");
        t._getNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                1 == o.result && (wx.showToast({
                    title: o.msg,
                    icon: "none",
                    duration: 1e3
                }), e.getData(), e.getUser());
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getGoodsCount: function() {
        var e = this, o = t.getNetAddresss("plugin.debt-shop.frontend.debt-member.applyData");
        t._getNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                1 == o.result && e.setData({
                    vip_goods_id: o.data.vip_goods_id,
                    vip_goods_count: o.data.vip_goods_count
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    renewPost: function() {
        var e = this;
        if (this.data.goodsTotal > this.data.vip_goods_count) wx.showToast({
            icon: "none",
            title: "拥有商品数量不足",
            duration: 1500
        }); else {
            var o = {
                id: this.data.renewUserId,
                count: this.data.goodsTotal
            }, a = t.getNetAddresss("plugin.debt-shop.frontend.debt-member.rechargeDebtMemberTime");
            t._getNetWork({
                url: a,
                data: o,
                success: function(t) {
                    var o = t.data;
                    1 == o.result ? (e.setData({
                        RenewShow: !1
                    }), wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1e3,
                        success: function() {
                            this.getData(), this.getUser();
                        }
                    })) : wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    getData: function() {
        var e = this, o = t.getNetAddresss("plugin.debt-shop.frontend.vip.baseData");
        t._getNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                1 == o.result ? e.setData({
                    datainfo: o.data
                }) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getUser: function() {
        var e = this, o = t.getNetAddresss("plugin.debt-shop.frontend.debt-member.getDebtData");
        t._getNetWork({
            url: o,
            data: {
                member_type: 3
            },
            success: function(t) {
                var o = t.data;
                1 == o.result ? e.setData({
                    userInfo: o.data
                }) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});